<template>
  <div class="tabcontrol">
    <div v-for="(item,index) in titles" class="tabcontrol-item" 
    :class="{active:currentIndex === index}" @click="tabclick(index)">
      <span>{{item}}</span></div>
  </div>
</template>
<script>
  export default {
    name :'tabcontrol',
    props:{
      titles:{
        type:Array,
        default(){
          return[]
        }
      }
    },
    data(){
      return{
        currentIndex:0
      }
    },
    methods:{
      tabclick(index){
        this.currentIndex = index
        this.$emit('tabclick',index)
      }
    }
  }
</script>
<style>
  .tabcontrol{
    display: flex;
    text-align: center;
    height: 40px;
    line-height: 40px;
    background-color: #fff;
  }
  .tabcontrol-item{
    flex: 1;
    font-size: 14px;
  }
  .active span{
    color: var(--color-high-text);
    border-bottom: 2px solid var(--color-tint);
  }
</style>